package com.example.tellwin.mine.act;

import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.example.tellwin.R;
import com.example.tellwin.base.CpBaseActivty;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class ChangePhoneActivity extends CpBaseActivty {

    @BindView(R.id.phone_et)
    EditText phoneEt;
    @BindView(R.id.verification_code_et)
    EditText verificationCodeEt;
    @BindView(R.id.send_code_tv)
    TextView sendCodeTv;
    @BindView(R.id.commit_btn)
    TextView commitBtn;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_change_phone);
        ButterKnife.bind(this);
        initViews();
        initEvents();
        initDatas();
    }

    @Override
    protected void initViews() {

    }

    @Override
    protected void initEvents() {
        phoneEt.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                setCommitBtnEnable();
            }

            @Override
            public void afterTextChanged(Editable s) {

            }
        });
        verificationCodeEt.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                setCommitBtnEnable();
            }

            @Override
            public void afterTextChanged(Editable s) {

            }
        });
    }

    @Override
    protected void initDatas() {
        setTitle(R.string.change_phone_number);
    }

    private void setCommitBtnEnable() {
        commitBtn.setEnabled(phoneEt.getText().toString().length() == 11 && verificationCodeEt.getText().toString().length() == 6);
    }

    @OnClick({R.id.send_code_tv, R.id.commit_btn})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.send_code_tv:
                break;
            case R.id.commit_btn:
                break;
        }
    }
}
